
Fx.Multi = Class({
	Implements: Events,
	elements: {},
	interval: 0,
	initialize: function(elements, interval){
		this.elements = elements;
		this.interval = interval;
	},
	start: function(fxs, fi) {
		var es = this.elements;
		var ei = this.interval;
		for(var x = 0; x<es.length; x++) {
			var eli = ei*x;
			var end = (!(x < (es.length-1)));
			this.sheduleElement(es[x], fxs, eli, fi, x, end);
		}
	},
	sheduleElement: function(elem, fxs, basicTimeout, fxsTimeout, en, end) {
		for(var x=0; x<fxs.length; x++) {
			var timeout = basicTimeout+(fxsTimeout*x);
			var myend = (!(x < (fxs.length-1)));
			var fe = (myend && end);
			this.sheduleFx(elem, fxs[x], timeout, en, fe);
		}
	},
	sheduleFx: function(elem, fx, timeout, en, end) {
		var multi = this;
		setTimeout(function() {
			elem.setStyles(fx);
			if (end) multi.fireEvent('complete');
		}, timeout);
	}
})